﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kugar.Core.BaseStruct;
using Newtonsoft.Json.Linq;

namespace Kugar.Tool.DataSync.ClientPlugin
{
    public interface IExporterPlugin
    {
        /// <summary>
        /// 初始化导出插件,并传入数据传输接口
        /// </summary>
        /// <param name="dataSender">数据传输使用的外部委托,在初始化的时候传入</param>
        void Initialize(ExporterDataSender dataSender);

        void Close();

    }

    public abstract class ExporterPluginBase : IExporterPlugin
    {
        private ExporterDataSender _dataSender = null;

        protected void SendData(string dataTypeName, JObject data)
        {
            _dataSender(dataTypeName, data);
        }

        void IExporterPlugin.Initialize(ExporterDataSender dataSender)
        {
            _dataSender = dataSender;
        }

        public virtual void Close()
        {
            throw new NotImplementedException();
        }
    }

    public delegate void ExporterDataSender(string dataTypeName, JObject data);

    public interface ITransfer
    {
        ResultReturn Send(string dataTypeName, JObject data);
    }
}
